<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Search Questions</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
    <h2>Search Questions</h2>
    <p>Enter a keyword to search for questions and answers.</p>

    <form action="/search" method="get">
        <div class="input-group mb-3">
            <input type="text" name="keyword" class="form-control" placeholder="Enter keyword..." th:value="${keyword}">
            <div class="input-group-append">
                <button class="btn btn-outline-secondary" type="submit">Search</button>
            </div>
        </div>
    </form>

    <div th:if="${questions}">
        <h3 th:if="${!questions.isEmpty()}">Search Results for "<span th:text="${keyword}"></span>"</h3>
        <h3 th:if="${questions.isEmpty()}">No results found for "<span th:text="${keyword}"></span>"</h3>

        <div th:each="question : ${questions}" class="card mb-3">
            <div class="card-header">
                <strong>Question from <span th:text="${question.sourceFile}"></span></strong>
            </div>
            <div class="card-body">
                <p class="card-text" th:text="${question.questionText}"></p>
                <hr>
                <h5>Answer:</h5>
                <p class="card-text" th:text="${question.answerText}"></p>
            </div>
        </div>
    </div>
    <hr>
    <a href="/upload" class="btn btn-secondary">Go to Upload Page</a>
</div>
</body>
</html> 